// Replication code for "Leveling the Field: Gender Inequity in Academia During COVID"
// Marwa Shalaby, Nermin Allam, and Gail J. Buttorff
// Date: April 9, 2021
// Stata: Version 16 IC
// Dataset: Leveling the Field_Shalaby et al.dta"

//Appendix C - Logit Models and Predicted Probability Figures

label define parent 1 "No children under 18" 2 "Children under 18"
label values parent parent

drop if gender>2
*recode research 
gen rhours_recode=0 if !missing(researchhours)
replace rhours_recode=1 if researchhours==1 //decreased 
drop if gender>2
label define decreased 0 "Hours increased/stayed same" 1 "Hours decreased"
label values rhours_recode decreased 

*Recode submit publications
gen subpubs_recode=0 if !missing(submit_pubs)
replace subpubs_recode=1 if submit_pubs==1 //decreased
label define decreased1 0 "Ability increased/stayed same" 1 "Ability decreased"
label values subpubs_recode decreased1

*recode nonresearch_workload
gen nonresearch_recode=0 if !missing(nonresearch_workload)
replace nonresearch_recode=1 if nonresearch_workload==3 //increased
label define increased 0 "Workload decreased/stayed same" 1 "Workload increased"
label values nonresearch_recode increased

* Variable for whether individual has partner
gen partner=0 if !missing(relationship_status)
replace partner=1 if relationship_status==1 
label define partner 0 "No partner" 1 "Partner"
label values partner partner

* Whether have tenure
gen tenured=0 if !missing(academicposition_recode)
replace tenured=1 if academicposition_recode==2 | academicposition_recode==3 //Associate and Full
label define tenured 0 "Not tenured" 1 "Tenured"
label values tenured tenured

set scheme plotplainblind

*UH Colors
global uh_red "200 16 46"
global uh_grey "136 139 141"
global uh_teal "0 179 136"
global uh_gold "246 190 0"
global uh_cream "255 249 217"


//Hours Devoted to Research - Polisci and Related Fields 
logit rhours_recode i.gender##i.parent i.partner i.tenured age if polisci_other==1
estimates store m1
margins gender, dydx(parent)

margins, at(tenured=0 partner=1) atmeans over(gender parent)
marginsplot, recast(bar) plotop(barw(.75) bc(grey%20)) ytitle("Predicted Probability", size(small)) xtitle("") ylab(0(.2)1) bydimension(parent) byopt(title("A. Hours devoted to research (decreased)", size(medsmall)))
graph save "rhours.gph", replace

//Ability to Submit Publications - Polisci and Related Fields

logit subpubs_recode i.gender##i.parent i.partner i.tenured age if polisci_other==1
estimates store m2
margins gender, dydx(parent)

margins, at(tenured=0 partner=1) atmeans over(gender parent)
marginsplot, recast(bar) plotop(barw(.75) bc(grey%20)) ytitle("Predicted Probability", size(small)) xtitle("") ylab(0(.2)1) bydimension(parent) byopt(title("B. Complete and/or submit work for publication (decreased)", size(medsmall)))
graph save "submit.gph", replace


//Non-research Workload - Polisci and Related Fields
logit nonresearch_recode i.gender##i.parent i.partner i.tenured age if polisci_other==1
estimates store m3
margins gender, dydx(parent)

margins, at(tenured=0 partner=1) atmeans over(gender parent)
marginsplot, recast(bar) plotop(barw(.75) bc(grey%20)) ytitle("Predicted Probability", size(small)) xtitle("") ylab(0(.2)1) bydimension(parent) byopt(title("C. Non-research-related workload (increased)", size(medsmall)))
graph save "service.gph", replace

graph combine "rhours.gph" "submit.gph" "service.gph", ycommon
graph export "PS_Figures/predicprob_polisci.png", replace width(1000)


//Hours Devoted to Research - All Disciplines
logit rhours_recode i.gender##i.parent i.partner i.tenured age
estimates store all1
margins gender, dydx(parent)

margins, at(tenured=0 partner=1) atmeans over(gender parent)
marginsplot, recast(bar) plotop(barw(.75) bc(grey%20)) ytitle("Predicted Probability", size(small)) xtitle("") ylab(0(.2)1) bydimension(parent) byopt(title("A. Hours devoted to research (decreased)", size(medsmall)))
graph save "rhoursFS.gph", replace


//Ability to Submit Publications - All Disciplines
logit subpubs_recode i.gender##i.parent i.partner i.tenured age 
estimates store all2
margins gender, dydx(parent)

margins, at(tenured=0 partner=1) atmeans over(gender parent)
marginsplot, recast(bar) plotop(barw(.75) bc(grey%20)) ytitle("Predicted Probability", size(small)) xtitle("") ylab(0(.2)1) bydimension(parent) byopt(title("B. Complete and/or submit work for publication (decreased)", size(medsmall)))
graph save "submitFS.gph", replace


//Non-research Workload - All Disciplines 
logit nonresearch_recode i.gender##i.parent i.partner i.tenured age
estimates store all3
margins gender, dydx(parent)

margins, at(tenured=0 partner=1) atmeans over(gender parent)
marginsplot, recast(bar) plotop(barw(.75) bc(grey%20)) ytitle("Predicted Probability", size(small)) xtitle("") ylab(0(.2)1) bydimension(parent) byopt(title("C. Non-research-related workload (increased)", size(medsmall)))
graph save "serviceFS.gph", replace

graph combine "rhoursFS.gph" "submitFS.gph" "serviceFS.gph", ycommon
graph export "PS_Figures/predicprob_all.png", replace width(1000)

estout m1 m2 m3 all1 all2 all3 using "regressionoutput2.txt", replace unstack ///
cells(b(fmt(3) star) se(par)) stats(N, fmt(0 0 )) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001)   

//Crosstabs for Main Text
//Political Science and Related Fields
tabout researchhours gender if polisci_other==1 using "polisci_gender.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) replace

tabout submit_pubs gender if polisci_other==1 using "polisci_gender.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append

tabout nonresearch_workload gender if polisci_other==1 using "polisci_gender.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append

tabout cchours_recode gender if polisci_other==1 using "polisci_gender.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append

tabout researchhours parent if polisci_other==1 using "polisci_parents.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) replace

tabout submit_pubs parent if polisci_other==1 using "polisci_parents.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append

tabout nonresearch_workload parent if polisci_other==1 using "polisci_parents.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append


foreach var of varlist cc_* {
	tabout `var' gender if polisci_other==1 using "polisci_ccare.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append 
}

//All Disciplines

drop if gender>2 //two respondents

tabout researchhours gender using "all_gender.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) replace

tabout submit_pubs gender using "all_gender.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append

tabout nonresearch_workload gender using "all_gender.csv", c(col freq) f(0 1)  style(csv)clab(Col_% No.) font(bold) stats(chi2) append

tabout cchours_recode gender using "all_gender.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append

tabout researchhours parent using "all_parents.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) replace

tabout submit_pubs parent using "all_parents.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append

tabout nonresearch_workload parent using "all_parents.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append

foreach var of varlist cc_* {
	tabout `var' gender using "all_ccare.csv", c(col freq) f(0 1)  style(csv) clab(Col_% No.) font(bold) stats(chi2) append 
}






